package com.hand.demo.config;

import org.hzero.boot.message.MessageClient;
import org.hzero.boot.message.entity.Attachment;
import org.hzero.boot.message.entity.Message;
import org.hzero.boot.message.entity.Receiver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 *
 */
@Component
public class MessageConfig {
    @Value("${my.hzero.message.tenantId}")
    private Long tenantId;
    @Value("${my.hzero.message.serverCode}")
    private String serverCode;
    @Value("${my.hzero.message.messageTemplateCode}")
    private String messageTemplateCode;
    @Value("${my.hzero.message.lang}")
    private String lang;

    @Autowired
    private MessageClient messageClient;

    /**
     * 发送邮件(指定抄送，密送)
     * @param receiverList        接收人列表
     * @param args                参数
     * @param ccList              抄送
     * @param bccList             密送
     * @param attachments         附件
     * @return 发送结果
     */
    Message sendEmail(List<Receiver> receiverList, Map<String, String> args,
                      List<String> ccList, List<String> bccList, Attachment... attachments) {
        return messageClient.sendEmail(tenantId, serverCode, messageTemplateCode, lang, receiverList,
                args, attachments);
    }
}
